<?php

namespace app\api\controller;

use think\Db;

use app\common\controller\Logined;

//问题反馈
class Assist extends Logined {

	public function setAssist(){
		$title   = P('title');
		$content = P('content');
		$type = P('type')?:'其他问题';
		$pic     = P('pic')?:"";
		$uid     = $this->uid;
		if(empty($title) || empty($content) || empty($uid)){
			$this->retData(1, '缺少参数');
		}
		$res = model('AssistModel')->addData($uid,$title,$content,$pic,$type);
		if($res){
			$this->retData(0, '操作成功，请等待客服回复~');
		} else {
			$this->retData(1, '操作失败');
		}
	}

	/*
	获取问题列表
	*/
	public function getAssist(){
		$uid = $this->uid;
		if(empty($uid)){
			$this->retData(1, '缺少参数');
		}
		$data = model('AssistModel')->getAssistList($uid);
		if($data){
			$this->retData(0,'success',$data);
		} else {
			$this->retData(0,'fail');
		}
	}

	/*
	问题详细
	*/
	public function assistDetail(){
		$uid = $this->uid;
		$id  = P('id');
		if(empty($uid) || empty($id)){
			$this->retData(1, '缺少参数');
		}
		$data = model('AssistModel')->getDetail($uid,$id);
		if($data){
			$this->retData(0,'success',$data);
		} else {
			$this->retData(0,'fail');
		}
	}
}